<template>
  <mavon-editor v-model="processedContent" />
</template>

<script>
import { mavonEditor } from 'mavon-editor';
import 'mavon-editor/dist/css/index.css';

export default {
  components: {
    mavonEditor
  },
  computed: {
    processedContent() {
      return this.markdownContent
        .replace(/\\\[/g, '$$')  // 将 \[ 替换为 $$
        .replace(/\\\]/g, '$$')  // 将 \] 替换为 $$
        .replace(/\\\\([^$])/g, '\\\\\\\\$1')  // 将 \\ 替换为 \\\\
        .replace(/\\\\(\\\\)/g, '\\\\\\\\');  // 将 \\\\ 替换为 \\\\\\\\
    }
  },
  data() {
    return {
      markdownContent: `

\\[
\\text{均值} (\\bar{x}) = \\frac{1}{N}\\sum_{i=1}^{N} x_i
\\]
\\[
\\text{中位数} = \\begin{cases} 
x_{(n+1)/2}, & \\text{当 }n \\text{是奇数} \\\\ 
\\frac{x_{(n/2)} + x_{(n/2 + 1)}}{2}, & \\text{当 }n \\text{是偶数} 
\\end{cases}
\\]
\\[
\\text{方差} (s^2) = \\frac{1}{N-1}\\sum_{i=1}^{N} (x_i - \\bar{x})^2
\\]
\\[
\\text{标准差} (s) = \\sqrt{s^2}
\\]
\\[
\\text{偏度} = \\frac{1}{N}\\sum_{i=1}^{N} \\left(\\frac{x_i - \\bar{x}}{s}\\right)^3
\\]
\\[
\\text{峰度} = \\frac{1}{N}\\sum_{i=1}^{N} \\left(\\frac{x_i - \\bar{x}}{s}\\right)^4 - 3
\\]
      `
    };
  }
};
</script>

<!-- 
<style scoped>
:deep(.v-note-op) {
  display: none !important;
}

:deep(.v-note-edit) {
  display: none !important;
}

:deep(.v-note-show) {
  width: 100% !important;
}

:deep(.v-note-panel) {
  display: block !important;
}
</style> -->